$.fn.is_match=function(selector)
                      {selector=selector.split(/\s+/).reverse().join(' ')
                                .split(' > ').join('").parent("')
                                .split(' + ').join('").prev("')
                                .split(' ~ ').join('").prevAll("')
                                .split(/\s+/).join('").parents("');
                       return eval('this.filter("'+selector+'").length');
                      }
$.live_bind=function(selector, etype, fn)
                    {var fn_tmp=function(event) //one fn_tmp per selector para
                                {var event=event || window.event,
                                 src_ele=event.srcElement || event.target;
                                 if (!src_ele.parentNode) 
                                    {return; //for parentNode maybe replaced by other bound events
                                    }
                                 if ($(src_ele).is_match(selector))
                                    {fn.call(src_ele, event); //for support 'this'
                                    }
                                };
                     if ($.inArray(etype, ['focus', 'blur'])=='-1')
                        {$(document).bind(etype, fn_tmp);
                        }
                     else
                         {if (document.addEventListener)
                             {document.addEventListener(etype, fn_tmp, true);
                             }
                          else
                              {etype=etype=='focus'?'focusin':'focusout';
                               document.attachEvent('on'+etype, fn_tmp);
                              }
                         }
                    };

$.fn.openCloseBlocks = function(blocks, options) 
{
    var defaults = 
    { 
        speed: 'normal'
    }, 
    opts         = $.extend(defaults, options),
      togglers     = $(this),
      bls         = $(blocks); if(!bls) return;
      
      togglers.each(function(index) {
          $(this).click(function(e) {
              e.preventDefault();             
              $(bls[index]).slideToggle(opts['speed']);
          });
      });
};

$.fn.dropDownBlock = function(block, options) 
{
    var defaults = 
    { 
        speed: 'fast',
        top: $(this).height(),
        left: 0, 
        z_index: 1000, 
        close_on_click: false
    }, 
    opts = $.extend(defaults, options),
    toggler = $(this),
    block = $(block);
    toggler.css({'outline': 'none'})
      
      toggler.click(function(e) 
      {
          //e.preventDefault();
          $(block).css({
            'position'  : 'absolute',
            'top'       : (toggler.offset().top + opts['top']) + 'px',
            'left'      : (toggler.offset().left + opts['left']) + 'px', 
            'z-index'   : opts['z_index']
          });
          if($(block).is(':visible')) $(block).fadeOut(opts['speed']);
          else $(block).fadeIn(opts['speed']);              
          this.focus();
      });
      if (opts['close_on_click']) {
          $(block).click(function()
          {
              $(this).fadeOut(opts['speed']);
          });
      }
};